package cn.wolfcode.rbac.config;

import cn.wolfcode.rbac.web.intercptor.CheckLoginIntercptor;
import cn.wolfcode.rbac.web.intercptor.SecurityIntercptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @version 1.0
 * @Author:Cao Zhijian
 * @DATE:2020/12/27 0027 22:01:47
 */
@Configuration
public class IntercptorConfig implements WebMvcConfigurer {

    @Autowired
    private CheckLoginIntercptor checkLoginIntercptor;

    @Autowired
    private SecurityIntercptor securityIntercptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkLoginIntercptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/login.html")
                ;

        registry.addInterceptor(securityIntercptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/login.html")
        ;

    }
}
